<script setup lang="ts">
import { mapPathToBreadCrumbs } from '@/utils/map-menus'
import useLogingStore from '@/store/modules/login'

const route = useRoute()
const userMenus = useLogingStore().userMenus
const breadcrumbs = computed(() => {
  // 路由跳转后面包屑导航不实时更新，所以这里将函数放到computed里，当数据发生变化时，computed会重新返回一个新的
  return mapPathToBreadCrumbs(route.path, userMenus)
})
</script>

<template>
  <div class="crumb">
    <el-breadcrumb separator-icon="ArrowRight">
      <template v-for="item in breadcrumbs" :key="item.name">
        <el-breadcrumb-item :to="item.path">{{ item.name }}</el-breadcrumb-item>
      </template>
    </el-breadcrumb>
  </div>
</template>

<style lang="less" scoped></style>
